package com.dhwl.hsh.driver.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dhwl.hsh.driver.R;
import com.dhwl.hsh.driver.ui.activity.OrderDetailActivity;
import com.dhwl.hsh.lib.bean.resp.OrderListResponse;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 货源列表适配器
 *
 * @author Derek.Kidd
 * @time 2016/4/23 17:06
 */
public class TaskListAdapter extends BaseAdapter<OrderListResponse> {


    public TaskListAdapter(Context context, List<OrderListResponse> list) {
        super(context, list);
    }

    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;
        if (null == convertView) {
            convertView = inflate(R.layout.item_layout_task, null);
            viewHolder = new ViewHolder(convertView);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
//        final OrderListResp item = getList().get(position);


        convertView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, OrderDetailActivity.class);
//                intent.putExtra("order_id", item.getOrder_id());
                context.startActivity(intent);
            }
        });


        return convertView;
    }


    static class ViewHolder {
        @Bind(R.id.tv_task_type)
        TextView tvTaskType;
        @Bind(R.id.tv_merchant_name)
        TextView tvMerchantName;
        @Bind(R.id.tv_merchant_rate)
        TextView tvMerchantRate;
        @Bind(R.id.tv_task_start_add)
        TextView tvTaskStartAdd;
        @Bind(R.id.tv_task_end_add)
        TextView tvTaskEndAdd;
        @Bind(R.id.tv_task_start_time)
        TextView tvTaskStartTime;
        @Bind(R.id.tv_task_truck_type)
        TextView tvTaskTruckType;
        @Bind(R.id.tv_task_remark)
        TextView tvTaskRemark;
        @Bind(R.id.tv_task_total_price)
        TextView tvTaskTotalPrice;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
